import {
	html2json,
	json2html
} from 'html2json'
	import {
		nanoid
	} from "nanoid"
	const md5 = require('js-md5')
export default{
	getJson() {
	let html = '<title title="图片 Image">'
	html +=
		'<u-image :showLoading="true" src="https://cdn.uviewui.com/uview/album/1.jpg" width="80px" height="80px" title="基本使用" ></u-image>'
    html += '<u-image src="https://cdn.uviewui.com/uview/album/1.jpg" width="80px" height="80px" mode="widthFix" title="图片模式(widthFit)" ></u-image>' 
	html += '<u-image src="https://cdn.uviewui.com/uview/album/1.jpg" width="80px" height="80px" radius="10" title="自定义圆角" ></u-image>'
	html += '<u-image src="https://cdn.uviewui.com/uview/album/1.jpg" width="80px" height="80px" shape="circle" title="圆形图片"></u-image>' 
	html += '</title>' 
	let json = html2json(html)
	// console.log(json.child)
	json.child.map((fv, fk) => {
		if (typeof fv.child != 'undefined') {
			fv.child.map((sv, sk) => {
				console.log(sv)
				sv.attr.compId = md5(JSON.stringify(sv))
				sv.h = 30
				sv.w = 375
				sv.isResize = false
				if (typeof sv.attr != 'undefined') {
					if (typeof sv.attr.size == 'undefined') {
						sv.attr.size = 'small'
					}
				}else{
					sv.attr = {size:'small'}
				}
			})
		}
	})
	console.log(json.child)	
	return json.child
}
}
